﻿/* ==============================================================================
 * 功能描述：PlayerAnimation  
 * 
 * 创 建 者：郑镇泉
 * 
 * 创建日期：2016/4/23 21:23:19
 * ==============================================================================*/
using UnityEngine;
using System.Collections;
using ZZQFrameWork;

/// <summary>
/// 角色移动方向
/// </summary>
public enum Enum_PlayerMoveDirection
{
    None,Up,Down,Left,Right
}

public class PlayerAnimator : MonoBehaviour
{
    [HideInInspector]
    public PlayerAI PlayerAI;

    private Animator animator;

    private Enum_PlayerMoveDirection moveDirection;

    void Awake()
    {
        animator = GetComponent<Animator>();
    }

    void Start()
    {
        animator.SetInteger("IdleDir",2);
    }

    public void SetMoveDirection(Enum_PlayerMoveDirection direction)
    {
        animator.SetInteger("IdleDir", 0);
        moveDirection = direction;
        switch (moveDirection)
        {
                case Enum_PlayerMoveDirection.Up:animator.SetInteger("MoveDir",1);
                    break;
                case Enum_PlayerMoveDirection.Down: animator.SetInteger("MoveDir", 2);
                    break;
                case Enum_PlayerMoveDirection.Right: animator.SetInteger("MoveDir", 4);
                    break;
                case Enum_PlayerMoveDirection.Left: animator.SetInteger("MoveDir", 3);
                    break;
        }
    }

    public void SetIdleDirection()
    {
        animator.SetInteger("MoveDir", 0);
        switch (moveDirection)
        {
            case Enum_PlayerMoveDirection.Up: animator.SetInteger("IdleDir", 1);
                break;
            case Enum_PlayerMoveDirection.Down: animator.SetInteger("IdleDir", 2);
                break;
            case Enum_PlayerMoveDirection.Right: animator.SetInteger("IdleDir", 4);
                break;
            case Enum_PlayerMoveDirection.Left: animator.SetInteger("IdleDir", 3);
                break;
        }
    }
}